package base

import "gitee.com/slion/infra"

// 实例化一个api的初始化器注册器
var apiInitializerRegister = new(infra.InitializerRegister)

// 注册WEB API初始化对象
func RegisterApi(initializer infra.Initializer) {
	apiInitializerRegister.Register(initializer)
}

// 获取所有注册的WEB API初始化对象
func GetApiInitializers() []infra.Initializer {
	return apiInitializerRegister.Initializers
}

type WebApiStarter struct {
	infra.BaseStarter
}

func (w *WebApiStarter) Setup(ctx infra.StartContext) {
	for _, v := range GetApiInitializers() {
		// 调用初始化器的Init()方法
		v.Init()
	}
}
